import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/goods_list_entity.dart';

GoodsListEntity $GoodsListEntityFromJson(Map<String, dynamic> json) {
  final GoodsListEntity goodsListEntity = GoodsListEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    goodsListEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    goodsListEntity.msg = msg;
  }
  final List<GoodsListData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<GoodsListData>(e) as GoodsListData)
      .toList();
  if (data != null) {
    goodsListEntity.data = data;
  }
  return goodsListEntity;
}

Map<String, dynamic> $GoodsListEntityToJson(GoodsListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension GoodsListEntityExtension on GoodsListEntity {
  GoodsListEntity copyWith({
    int? code,
    String? msg,
    List<GoodsListData>? data,
  }) {
    return GoodsListEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

GoodsListData $GoodsListDataFromJson(Map<String, dynamic> json) {
  final GoodsListData goodsListData = GoodsListData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsListData.id = id;
  }
  final int? isSelf = jsonConvert.convert<int>(json['is_self']);
  if (isSelf != null) {
    goodsListData.isSelf = isSelf;
  }
  final String? isDeductible = jsonConvert.convert<String>(json['is_deductible']);
  if (isDeductible != null) {
    goodsListData.isDeductible = isDeductible;
  }

  final String? imgUrl = jsonConvert.convert<String>(json['img_url']);
  if (imgUrl != null) {
    goodsListData.imgUrl = imgUrl;
  }
  final String? addTime = jsonConvert.convert<String>(json['add_time']);
  if (addTime != null) {
    goodsListData.addTime = addTime;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    goodsListData.title = title;
  }
  final String? baopei = jsonConvert.convert<String>(json['baopei']);
  if (baopei != null) {
    goodsListData.baopei = baopei;
  }

  final String? categoryText = jsonConvert.convert<String>(
      json['category_text']);
  if (categoryText != null) {
    goodsListData.categoryText = categoryText;
  }
  final String? sellPrice = jsonConvert.convert<String>(json['sell_price']);
  if (sellPrice != null) {
    goodsListData.sellPrice = sellPrice;
  }
  final String? channelId = jsonConvert.convert<String>(json['channel_id']);
  if (channelId != null) {
    goodsListData.channelId = channelId;
  }
  final String? channelName = jsonConvert.convert<String>(json['channel_name']);
  if (channelName != null) {
    goodsListData.channelName = channelName;
  }
  final int? totalcount = jsonConvert.convert<int>(json['totalcount']);
  if (totalcount != null) {
    goodsListData.totalcount = totalcount;
  }
  return goodsListData;
}

Map<String, dynamic> $GoodsListDataToJson(GoodsListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['is_self'] = entity.isSelf;
  data['img_url'] = entity.imgUrl;
  data['add_time'] = entity.addTime;
  data['is_deductible'] = entity.isDeductible;

  data['baopei'] = entity.baopei;
  data['title'] = entity.title;
  data['category_text'] = entity.categoryText;
  data['sell_price'] = entity.sellPrice;
  data['channel_id'] = entity.channelId;
  data['channel_name'] = entity.channelName;
  data['totalcount'] = entity.totalcount;
  return data;
}

extension GoodsListDataExtension on GoodsListData {
  GoodsListData copyWith({
    int? id,
    int? isSelf,
    String? baopei,
    String? imgUrl,
    String? addTime,
    String? title,
    String? categoryText,
    String? sellPrice,
    String? channelId,
    String? isDeductible,
    String? channelName,
    int? totalcount,
  }) {
    return GoodsListData()
      ..id = id ?? this.id
      ..baopei = baopei ?? this.baopei
      ..isSelf = isSelf ?? this.isSelf
      ..imgUrl = imgUrl ?? this.imgUrl
      ..addTime = addTime ?? this.addTime
      ..isDeductible = isDeductible ?? this.isDeductible
      ..title = title ?? this.title
      ..categoryText = categoryText ?? this.categoryText
      ..sellPrice = sellPrice ?? this.sellPrice
      ..channelId = channelId ?? this.channelId
      ..channelName = channelName ?? this.channelName
      ..totalcount = totalcount ?? this.totalcount;
  }
}